<?PHP
//$idCliente
	include_once "ProductControl.php";
	
	$label_name = mysql_real_escape_string($_POST["name"]);
	$label_type = $_POST["select"];
	$label_quantity = mysql_real_escape_string($_POST["quantity"]);
	$label_amount = mysql_real_escape_string($_POST["amount"]);
	$label_artist = mysql_real_escape_string($_POST["artist"]);
	$label_country = mysql_real_escape_string($_POST["country"]);
	$label_description = mysql_real_escape_string($_POST["description"]);
	
	$idProduto= $_GET["idp"];
	
	$result = ProductControl::atualizaProduto($idProduto, $label_name, $label_quantity, $label_amount, 
	$label_type, $label_artist, $label_country, $label_description);
	
	if($result)
	{
		$photo = "photo";
	$count = 0;
	
	//while
	
	$foto = $_FILES[$photo];
	$tmp_name  = $_FILES['photo']['tmp_name'];
	$file_size = $_FILES['photo']['size'];
	$type = $_FILES['photo']['type'];
	if($tmp_name != null)
	{
		
		$fp = fopen($tmp_name, 'r');
		$file_content = fread($fp, $file_size) or die("Error: cannot read file");
		$file_content = addslashes($file_content) or die("Error: cannot read file");
		fclose($fp);
		
		ProductControl::InsertPhoto($file_content, ".".substr($type, 6) ,$product->Id);
	}
	
		header ("Location: index.php?product_form_success=true");
	}
	else
	{
		header ("Location: EditarProdutoAdmin.php?product_form_success=false");
	}
?>